/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.ieorganic.modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Amalia
 */
@Entity
@Table(name = "ingresos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ingresos.findAll", query = "SELECT i FROM Ingresos i"),
    @NamedQuery(name = "Ingresos.findByIdIngresos", query = "SELECT i FROM Ingresos i WHERE i.idIngresos = :idIngresos"),
    @NamedQuery(name = "Ingresos.findByCantidadDeCajasVendidas", query = "SELECT i FROM Ingresos i WHERE i.cantidadDeCajasVendidas = :cantidadDeCajasVendidas"),
    @NamedQuery(name = "Ingresos.findByCostoPorCaja", query = "SELECT i FROM Ingresos i WHERE i.costoPorCaja = :costoPorCaja")})
public class Ingresos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idIngresos")
    private Integer idIngresos;
    @Basic(optional = false)
    @NotNull
    @Column(name = "cantidad de cajas vendidas")
    private int cantidadDeCajasVendidas;
    @Basic(optional = false)
    @NotNull
    @Column(name = "costo por caja")
    private long costoPorCaja;
    @ManyToMany(mappedBy = "ingresosList")
    private List<Egresos> egresosList;
    @JoinColumn(name = "Administrador_idAdministrador", referencedColumnName = "idAdministrador")
    @ManyToOne(optional = false)
    private Administrador administradoridAdministrador;

    public Ingresos() {
    }

    public Ingresos(Integer idIngresos) {
        this.idIngresos = idIngresos;
    }

    public Ingresos(Integer idIngresos, int cantidadDeCajasVendidas, long costoPorCaja) {
        this.idIngresos = idIngresos;
        this.cantidadDeCajasVendidas = cantidadDeCajasVendidas;
        this.costoPorCaja = costoPorCaja;
    }

    public Integer getIdIngresos() {
        return idIngresos;
    }

    public void setIdIngresos(Integer idIngresos) {
        this.idIngresos = idIngresos;
    }

    public int getCantidadDeCajasVendidas() {
        return cantidadDeCajasVendidas;
    }

    public void setCantidadDeCajasVendidas(int cantidadDeCajasVendidas) {
        this.cantidadDeCajasVendidas = cantidadDeCajasVendidas;
    }

    public long getCostoPorCaja() {
        return costoPorCaja;
    }

    public void setCostoPorCaja(long costoPorCaja) {
        this.costoPorCaja = costoPorCaja;
    }

    @XmlTransient
    public List<Egresos> getEgresosList() {
        return egresosList;
    }

    public void setEgresosList(List<Egresos> egresosList) {
        this.egresosList = egresosList;
    }

    public Administrador getAdministradoridAdministrador() {
        return administradoridAdministrador;
    }

    public void setAdministradoridAdministrador(Administrador administradoridAdministrador) {
        this.administradoridAdministrador = administradoridAdministrador;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idIngresos != null ? idIngresos.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ingresos)) {
            return false;
        }
        Ingresos other = (Ingresos) object;
        if ((this.idIngresos == null && other.idIngresos != null) || (this.idIngresos != null && !this.idIngresos.equals(other.idIngresos))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "mx.itschapala.dsw2.ieorganic.modelo.Ingresos[ idIngresos=" + idIngresos + " ]";
    }
    
}
